home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / mozilla-firefox / include / xpcom / nsIPipe.h < prev    next >
Encoding:
C/C++ Source or Header  |  2006-05-08  |  12.8 KB  |  330 lines

  1. /*
  2.  * DO NOT EDIT.  THIS FILE IS GENERATED FROM nsIPipe.idl
  3.  */
  4.  
  5. #ifndef __gen_nsIPipe_h__
  6. #define __gen_nsIPipe_h__
  7.  
  8.  
  9. #ifndef __gen_nsIAsyncInputStream_h__
  10. #include "nsIAsyncInputStream.h"
  11. #endif
  12.  
  13. #ifndef __gen_nsIAsyncOutputStream_h__
  14. #include "nsIAsyncOutputStream.h"
  15. #endif
  16.  
  17. /* For IDL files that don't want to include root IDL files. */
  18. #ifndef NS_NO_VTABLE
  19. #define NS_NO_VTABLE
  20. #endif
  21. class nsIMemory; /* forward declaration */
  22.  
  23.  
  24. /* starting interface:    nsIPipe */
  25. #define NS_IPIPE_IID_STR "f4211abc-61b3-11d4-9877-00c04fa0cf4a"
  26.  
  27. #define NS_IPIPE_IID \
  28.   {0xf4211abc, 0x61b3, 0x11d4, \
  29.     { 0x98, 0x77, 0x00, 0xc0, 0x4f, 0xa0, 0xcf, 0x4a }}
  30.  
  31. /**
  32.  * nsIPipe represents an in-process buffer that can be read using nsIInputStream
  33.  * and written using nsIOutputStream.  The reader and writer of a pipe do not
  34.  * have to be on the same thread.  As a result, the pipe is an ideal mechanism
  35.  * to bridge data exchange between two threads.  For example, a worker thread
  36.  * might write data to a pipe from which the main thread will read.
  37.  *
  38.  * Each end of the pipe can be either blocking or non-blocking.  Recall that a
  39.  * non-blocking stream will return NS_BASE_STREAM_WOULD_BLOCK if it cannot be
  40.  * read or written to without blocking the calling thread.  For example, if you
  41.  * try to read from an empty pipe that has not yet been closed, then if that
  42.  * pipe's input end is non-blocking, then the read call will fail immediately
  43.  * with NS_BASE_STREAM_WOULD_BLOCK as the error condition.  However, if that
  44.  * pipe's input end is blocking, then the read call will not return until the
  45.  * pipe has data or until the pipe is closed.  This example presumes that the
  46.  * pipe is being filled asynchronously on some background thread.
  47.  *
  48.  * The pipe supports nsIAsyncInputStream and nsIAsyncOutputStream, which give
  49.  * the user of a non-blocking pipe the ability to wait for the pipe to become
  50.  * ready again.  For example, in the case of an empty non-blocking pipe, the
  51.  * user can call AsyncWait on the input end of the pipe to be notified when 
  52.  * the pipe has data to read (or when the pipe becomes closed).
  53.  *
  54.  * NS_NewPipe2 and NS_NewPipe provide convenient pipe constructors.  In most
  55.  * cases nsIPipe is not actually used.  It is usually enough to just get
  56.  * references to the pipe's input and output end.  In which case, the pipe is
  57.  * automatically closed when the respective pipe ends are released.
  58.  */
  59. class NS_NO_VTABLE nsIPipe : public nsISupports {
  60.  public: 
  61.  
  62.   NS_DEFINE_STATIC_IID_ACCESSOR(NS_IPIPE_IID)
  63.  
  64.   /**
  65.      * initialize this pipe
  66.      */
  67.   /* void init (in boolean nonBlockingInput, in boolean nonBlockingOutput, in unsigned long segmentSize, in unsigned long segmentCount, in nsIMemory segmentAllocator); */
  68.   NS_IMETHOD Init(PRBool nonBlockingInput, PRBool nonBlockingOutput, PRUint32 segmentSize, PRUint32 segmentCount, nsIMemory *segmentAllocator) = 0;
  69.  
  70.   /**
  71.      * The pipe's input end, which also implements nsISearchableInputStream.
  72.      */
  73.   /* readonly attribute nsIAsyncInputStream inputStream; */
  74.   NS_IMETHOD GetInputStream(nsIAsyncInputStream * *aInputStream) = 0;
  75.  
  76.   /**
  77.      * The pipe's output end.
  78.      */
  79.   /* readonly attribute nsIAsyncOutputStream outputStream; */
  80.   NS_IMETHOD GetOutputStream(nsIAsyncOutputStream * *aOutputStream) = 0;
  81.  
  82. };
  83.  
  84. /* Use this macro when declaring classes that implement this interface. */
  85. #define NS_DECL_NSIPIPE \
  86.   NS_IMETHOD Init(PRBool nonBlockingInput, PRBool nonBlockingOutput, PRUint32 segmentSize, PRUint32 segmentCount, nsIMemory *segmentAllocator); \
  87.   NS_IMETHOD GetInputStream(nsIAsyncInputStream * *aInputStream); \
  88.   NS_IMETHOD GetOutputStream(nsIAsyncOutputStream * *aOutputStream); 
  89.  
  90. /* Use this macro to declare functions that forward the behavior of this interface to another object. */
  91. #define NS_FORWARD_NSIPIPE(_to) \
  92.   NS_IMETHOD Init(PRBool nonBlockingInput, PRBool nonBlockingOutput, PRUint32 segmentSize, PRUint32 segmentCount, nsIMemory *segmentAllocator) { return _to Init(nonBlockingInput, nonBlockingOutput, segmentSize, segmentCount, segmentAllocator); } \
  93.   NS_IMETHOD GetInputStream(nsIAsyncInputStream * *aInputStream) { return _to GetInputStream(aInputStream); } \
  94.   NS_IMETHOD GetOutputStream(nsIAsyncOutputStream * *aOutputStream) { return _to GetOutputStream(aOutputStream); } 
  95.  
  96. /* Use this macro to declare functions that forward the behavior of this interface to another object in a safe way. */
  97. #define NS_FORWARD_SAFE_NSIPIPE(_to) \
  98.   NS_IMETHOD Init(PRBool nonBlockingInput, PRBool nonBlockingOutput, PRUint32 segmentSize, PRUint32 segmentCount, nsIMemory *segmentAllocator) { return !_to ? NS_ERROR_NULL_POINTER : _to->Init(nonBlockingInput, nonBlockingOutput, segmentSize, segmentCount, segmentAllocator); } \
  99.   NS_IMETHOD GetInputStream(nsIAsyncInputStream * *aInputStream) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetInputStream(aInputStream); } \
  100.   NS_IMETHOD GetOutputStream(nsIAsyncOutputStream * *aOutputStream) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetOutputStream(aOutputStream); } 
  101.  
  102. #if 0
  103. /* Use the code below as a template for the implementation class for this interface. */
  104.  
  105. /* Header file */
  106. class nsPipe : public nsIPipe
  107. {
  108. public:
  109.   NS_DECL_ISUPPORTS
  110.   NS_DECL_NSIPIPE
  111.  
  112.   nsPipe();
  113.  
  114. private:
  115.   ~nsPipe();
  116.  
  117. protected:
  118.   /* additional members */
  119. };
  120.  
  121. /* Implementation file */
  122. NS_IMPL_ISUPPORTS1(nsPipe, nsIPipe)
  123.  
  124. nsPipe::nsPipe()
  125. {
  126.   /* member initializers and constructor code */
  127. }
  128.  
  129. nsPipe::~nsPipe()
  130. {
  131.   /* destructor code */
  132. }
  133.  
  134. /* void init (in boolean nonBlockingInput, in boolean nonBlockingOutput, in unsigned long segmentSize, in unsigned long segmentCount, in nsIMemory segmentAllocator); */
  135. NS_IMETHODIMP nsPipe::Init(PRBool nonBlockingInput, PRBool nonBlockingOutput, PRUint32 segmentSize, PRUint32 segmentCount, nsIMemory *segmentAllocator)
  136. {
  137.     return NS_ERROR_NOT_IMPLEMENTED;
  138. }
  139.  
  140. /* readonly attribute nsIAsyncInputStream inputStream; */
  141. NS_IMETHODIMP nsPipe::GetInputStream(nsIAsyncInputStream * *aInputStream)
  142. {
  143.     return NS_ERROR_NOT_IMPLEMENTED;
  144. }
  145.  
  146. /* readonly attribute nsIAsyncOutputStream outputStream; */
  147. NS_IMETHODIMP nsPipe::GetOutputStream(nsIAsyncOutputStream * *aOutputStream)
  148. {
  149.     return NS_ERROR_NOT_IMPLEMENTED;
  150. }
  151.  
  152. /* End of implementation class template. */
  153. #endif
  154.  
  155.  
  156. /* starting interface:    nsISearchableInputStream */
  157. #define NS_ISEARCHABLEINPUTSTREAM_IID_STR "8c39ef62-f7c9-11d4-98f5-001083010e9b"
  158.  
  159. #define NS_ISEARCHABLEINPUTSTREAM_IID \
  160.   {0x8c39ef62, 0xf7c9, 0x11d4, \
  161.     { 0x98, 0xf5, 0x00, 0x10, 0x83, 0x01, 0x0e, 0x9b }}
  162.  
  163. /**
  164.  * XXX this interface doesn't really belong in here.  It is here because
  165.  * currently nsPipeInputStream is the only implementation of this interface.
  166.  */
  167. class NS_NO_VTABLE nsISearchableInputStream : public nsISupports {
  168.  public: 
  169.  
  170.   NS_DEFINE_STATIC_IID_ACCESSOR(NS_ISEARCHABLEINPUTSTREAM_IID)
  171.  
  172.   /**
  173.      * Searches for a string in the input stream. Since the stream has a notion
  174.      * of EOF, it is possible that the string may at some time be in the 
  175.      * buffer, but is is not currently found up to some offset. Consequently,
  176.      * both the found and not found cases return an offset:
  177.      *    if found, return offset where it was found
  178.      *    if not found, return offset of the first byte not searched
  179.      * In the case the stream is at EOF and the string is not found, the first
  180.      * byte not searched will correspond to the length of the buffer.
  181.      */
  182.   /* void search (in string forString, in boolean ignoreCase, out boolean found, out unsigned long offsetSearchedTo); */
  183.   NS_IMETHOD Search(const char *forString, PRBool ignoreCase, PRBool *found, PRUint32 *offsetSearchedTo) = 0;
  184.  
  185. };
  186.  
  187. /* Use this macro when declaring classes that implement this interface. */
  188. #define NS_DECL_NSISEARCHABLEINPUTSTREAM \
  189.   NS_IMETHOD Search(const char *forString, PRBool ignoreCase, PRBool *found, PRUint32 *offsetSearchedTo); 
  190.  
  191. /* Use this macro to declare functions that forward the behavior of this interface to another object. */
  192. #define NS_FORWARD_NSISEARCHABLEINPUTSTREAM(_to) \
  193.   NS_IMETHOD Search(const char *forString, PRBool ignoreCase, PRBool *found, PRUint32 *offsetSearchedTo) { return _to Search(forString, ignoreCase, found, offsetSearchedTo); } 
  194.  
  195. /* Use this macro to declare functions that forward the behavior of this interface to another object in a safe way. */
  196. #define NS_FORWARD_SAFE_NSISEARCHABLEINPUTSTREAM(_to) \
  197.   NS_IMETHOD Search(const char *forString, PRBool ignoreCase, PRBool *found, PRUint32 *offsetSearchedTo) { return !_to ? NS_ERROR_NULL_POINTER : _to->Search(forString, ignoreCase, found, offsetSearchedTo); } 
  198.  
  199. #if 0
  200. /* Use the code below as a template for the implementation class for this interface. */
  201.  
  202. /* Header file */
  203. class nsSearchableInputStream : public nsISearchableInputStream
  204. {
  205. public:
  206.   NS_DECL_ISUPPORTS
  207.   NS_DECL_NSISEARCHABLEINPUTSTREAM
  208.  
  209.   nsSearchableInputStream();
  210.  
  211. private:
  212.   ~nsSearchableInputStream();
  213.  
  214. protected:
  215.   /* additional members */
  216. };
  217.  
  218. /* Implementation file */
  219. NS_IMPL_ISUPPORTS1(nsSearchableInputStream, nsISearchableInputStream)
  220.  
  221. nsSearchableInputStream::nsSearchableInputStream()
  222. {
  223.   /* member initializers and constructor code */
  224. }
  225.  
  226. nsSearchableInputStream::~nsSearchableInputStream()
  227. {
  228.   /* destructor code */
  229. }
  230.  
  231. /* void search (in string forString, in boolean ignoreCase, out boolean found, out unsigned long offsetSearchedTo); */
  232. NS_IMETHODIMP nsSearchableInputStream::Search(const char *forString, PRBool ignoreCase, PRBool *found, PRUint32 *offsetSearchedTo)
  233. {
  234.     return NS_ERROR_NOT_IMPLEMENTED;
  235. }
  236.  
  237. /* End of implementation class template. */
  238. #endif
  239.  
  240. /**
  241.  * NS_NewPipe2
  242.  *
  243.  * This function supercedes NS_NewPipe.  It differs from NS_NewPipe in two
  244.  * major ways:
  245.  *  (1) returns nsIAsyncInputStream and nsIAsyncOutputStream, so it is
  246.  *      not necessary to QI in order to access these interfaces.
  247.  *  (2) the size of the pipe is determined by the number of segments
  248.  *      times the size of each segment.
  249.  *
  250.  * @param pipeIn
  251.  *        resulting input end of the pipe
  252.  * @param pipeOut
  253.  *        resulting output end of the pipe
  254.  * @param nonBlockingInput
  255.  *        true specifies non-blocking input stream behavior
  256.  * @param nonBlockingOutput
  257.  *        true specifies non-blocking output stream behavior
  258.  * @param segmentSize
  259.  *        specifies the segment size in bytes (pass 0 to use default value)
  260.  * @param segmentCount
  261.  *        specifies the max number of segments (pass 0 to use default value)
  262.  *        passing PR_UINT32_MAX here causes the pipe to have "infinite" space.
  263.  *        this mode can be useful in some cases, but should always be used with
  264.  *        caution.  the default value for this parameter is a finite value.
  265.  * @param segmentAlloc
  266.  *        pass reference to nsIMemory to have all pipe allocations use this
  267.  *        allocator (pass null to use the default allocator)
  268.  */
  269. extern NS_COM nsresult
  270. NS_NewPipe2(nsIAsyncInputStream **pipeIn,
  271.             nsIAsyncOutputStream **pipeOut,
  272.             PRBool nonBlockingInput = PR_FALSE,
  273.             PRBool nonBlockingOutput = PR_FALSE,
  274.             PRUint32 segmentSize = 0,
  275.             PRUint32 segmentCount = 0,
  276.             nsIMemory *segmentAlloc = nsnull);
  277. /**
  278.  * NS_NewPipe
  279.  *
  280.  * Preserved for backwards compatibility.  Plus, this interface is more
  281.  * amiable in certain contexts (e.g., when you don't need the pipe's async
  282.  * capabilities).
  283.  *
  284.  * @param pipeIn
  285.  *        resulting input end of the pipe
  286.  * @param pipeOut
  287.  *        resulting output end of the pipe
  288.  * @param segmentSize
  289.  *        specifies the segment size in bytes (pass 0 to use default value)
  290.  * @param maxSize
  291.  *        specifies the max size of the pipe (pass 0 to use default value)
  292.  *        number of segments is maxSize / segmentSize, and maxSize must be a
  293.  *        multiple of segmentSize.  passing PR_UINT32_MAX here causes the
  294.  *        pipe to have "infinite" space.  this mode can be useful in some
  295.  *        cases, but should always be used with caution.  the default value
  296.  *        for this parameter is a finite value.
  297.  * @param nonBlockingInput
  298.  *        true specifies non-blocking input stream behavior
  299.  * @param nonBlockingOutput
  300.  *        true specifies non-blocking output stream behavior
  301.  * @param segmentAlloc
  302.  *        pass reference to nsIMemory to have all pipe allocations use this
  303.  *        allocator (pass null to use the default allocator)
  304.  */
  305. inline nsresult
  306. NS_NewPipe(nsIInputStream **pipeIn,
  307.            nsIOutputStream **pipeOut,
  308.            PRUint32 segmentSize = 0,
  309.            PRUint32 maxSize = 0,
  310.            PRBool nonBlockingInput = PR_FALSE,
  311.            PRBool nonBlockingOutput = PR_FALSE,
  312.            nsIMemory *segmentAlloc = nsnull)
  313. {
  314.     PRUint32 segmentCount;
  315.     if (segmentSize == 0)
  316.         segmentCount = 0; // use default
  317.     else
  318.         segmentCount = maxSize / segmentSize;
  319.     nsIAsyncInputStream *in;
  320.     nsIAsyncOutputStream *out;
  321.     nsresult rv = NS_NewPipe2(&in, &out, nonBlockingInput, nonBlockingOutput,
  322.                               segmentSize, segmentCount, segmentAlloc);
  323.     if (NS_FAILED(rv)) return rv;
  324.     *pipeIn = in;
  325.     *pipeOut = out;
  326.     return NS_OK;
  327. }
  328.  
  329. #endif /* __gen_nsIPipe_h__ */
  330.